package com.tuananh.radnom.gwt.shared.dto;

import java.util.ArrayList;

import com.google.gwt.xml.client.Document;
import com.google.gwt.xml.client.XMLParser;
import com.sencha.gxt.data.shared.TreeStore;

public class NetNodeDTO extends NetElementDTO {

	ArrayList<NetInterfaceDTO> netInterfaces;
	MyBaseDTO techInfo;
	MyBaseDTO geoInfo;

	public ArrayList<NetInterfaceDTO> getNetInterfaces() {
		return netInterfaces;
	}

	public void setNetInterfaces(ArrayList<NetInterfaceDTO> netInterfaces) {
		this.netInterfaces = netInterfaces;
	}

	public MyBaseDTO getTechInfo() {
		return techInfo;
	}

	public void setTechInfo(MyBaseDTO techInfo) {
		this.techInfo = techInfo;
	}

	public MyBaseDTO getGeoInfo() {
		return geoInfo;
	}

	public void setGeoInfo(MyBaseDTO geoInfo) {
		this.geoInfo = geoInfo;
	}

	@Override
	public MyBaseDTO getData() {
		// TODO Auto-generated method stub
		MyBaseDTO result = new MyBaseDTO(this.getName(), this.getValue());
		result.getChildren().add(geoInfo);
		result.getChildren().add(techInfo);
		result.getChildren().addAll(netInterfaces);
		return super.getData();
	}

	@Override
	public MyBaseDTO addToTreeStore(MyBaseDTO root, String prefix,
			TreeStore<MyBaseDTO> store) {
		// TODO Auto-generated method stub
		if (root != null) {
			parentDTO = super.addToTreeStore(root, prefix, store);
			if (geoInfo != null)
				validateAndAdd(this, "GeoInfo", geoInfo, store);
			if (techInfo != null)
				validateAndAdd(this, "TechInfo", techInfo, store);
			MyBaseDTO listInterface = new MyBaseDTO("Interfaces",
					"List Interface");
			validateAndAdd(this, "", listInterface, store);
			for (NetInterfaceDTO netInt : netInterfaces) {
				netInt.addToTreeStore(listInterface, "", store);
			}
		}
		return parentDTO;
	}
	public String marshall(){
		Document doc = XMLParser.createDocument();
		doc.appendChild(doc.createElement("node"));
		return descript;	
	}
}
